<template>
    <div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/order_list' }">运单列表</el-breadcrumb-item>
        <el-breadcrumb-item>添加标签</el-breadcrumb-item>
        </el-breadcrumb><br>
        
        <p>添加标签</p>
        <center>
            <div style="width:300px;border:solid 1px gray;padding:20px;margin-top:120px;border-radius:20px">
                <el-form label-width="80px" class="demo-ruleForm" v-if="create_table">
                    <el-form-item label='标签ID :'>
                        <el-input placeholder='请输入' v-model="tag_number"></el-input>
                    </el-form-item>
                    <el-form-item label="货物类型 :">
                        <el-select v-model="goods_type" placeholder="请选择">
                        <el-option v-for="(item,index) in goods_type_list" :key="index" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="分配用户 :">
                        <el-select v-model="user" placeholder="请选择">
                        <el-option v-for="(item,index) in user_list" :key="index" :label="item.username" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="tags_created">添加</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </center>
    </div>
        
</template>
<script>
import {get_create_user_get,get_customer_list_get,get_goods_type_list_get,get_user_list_get,get_create_tags_get} from './axios_api/api.js'
export default {
    data(){
        return {
            create_table: true,
            tag_number: '',
            goods_type: '',
            user: '',
            user_list: [],
            goods_type_list: []
        }
    },
    mounted() {
        this.get_goods_type_list()
        this.get_user_list()
    },
    methods: {
        tags_created() {
            get_create_tags_get({tag_number: this.tag_number, goods_type: this.goods_type, user: this.user,uid: localStorage.getItem('uid')}).then(res => {
                console.log(res)
            })
        },
        get_goods_type_list() {
            get_goods_type_list_get().then(res => {
                this.goods_type_list = res.goods_type_list
            })
        },
        get_user_list(){
            get_user_list_get().then(res => {
                this.user_list = res.user_list
            })
        }
    }
}
</script>